-- Decompiled with the Synapse X Luau decompiler.

local v1 = {
	["\\t"] = "\t", 
	["\\f"] = "\012", 
	["\\r"] = "\r", 
	["\\n"] = "\n", 
	["\\b"] = "\008"
};
local v2 = {};
local l__string__1 = string;
function v2.__index(p1, p2)
	return l__string__1.sub(p2, 2);
end;
setmetatable(v1, v2);
local u2 = {
	["\""] = "\\\"", 
	["\\"] = "\\\\", 
	["/"] = "\\/", 
	["\008"] = "\\b", 
	["\012"] = "\\f", 
	["\n"] = "\\n", 
	["\r"] = "\\r", 
	["\t"] = "\\t"
};
local u3 = {
	EMPTY_ARRAY = {}, 
	EMPTY_OBJECT = {}
};
local l__math__4 = math;
local function u5(p3)
	local v3 = type(p3);
	local v4 = true;
	if v3 ~= "string" then
		v4 = true;
		if v3 ~= "boolean" then
			v4 = true;
			if v3 ~= "number" then
				v4 = true;
				if v3 ~= "nil" then
					v4 = true;
					if v3 ~= "table" then
						v4 = false;
						if v3 == "function" then
							v4 = p3 == u3.null;
						end;
					end;
				end;
			end;
		end;
	end;
	return v4;
end;
local l__table__6 = table;
local function u7(p4, p5)
	while l__string__1.find(" \n\r\t", l__string__1.sub(p4, p5, p5), 1, true) and p5 <= l__string__1.len(p4) do
		p5 = p5 + 1;	
	end;
	return p5;
end;
local function u8(p6, p7)
	local v5 = {};
	local v6 = l__string__1.len(p6);
	assert(l__string__1.sub(p6, p7, p7) == "{", "decode_scanObject called but object does not start at position " .. p7 .. " in string:\n" .. p6);
	p7 = p7 + 1;
	while true do
		p7 = u7(p6, p7);
		assert(p7 <= v6, "JSON string ended unexpectedly while scanning object.");
		local v7 = l__string__1.sub(p6, p7, p7);
		if v7 == "}" then
			break;
		end;
		if v7 == "," then
			p7 = u7(p6, p7 + 1);
		end;
		assert(p7 <= v6, "JSON string ended unexpectedly scanning object.");
		local v8, v9 = u3.decode(p6, p7);
		p7 = v9;
		assert(p7 <= v6, "JSON string ended unexpectedly searching for value of key " .. v8);
		p7 = u7(p6, p7);
		assert(p7 <= v6, "JSON string ended unexpectedly searching for value of key " .. v8);
		assert(l__string__1.sub(p6, p7, p7) == ":", "JSON object key-value assignment mal-formed at " .. p7);
		p7 = u7(p6, p7 + 1);
		assert(p7 <= v6, "JSON string ended unexpectedly searching for value of key " .. v8);
		local v10, v11 = u3.decode(p6, p7);
		p7 = v11;
		v5[v8] = v10;	
	end;
	return v5, p7 + 1;
end;
local function u9(p8, p9)
	local v12 = {};
	local v13 = l__string__1.len(p8);
	assert(l__string__1.sub(p8, p9, p9) == "[", "decode_scanArray called but array does not start at position " .. p9 .. " in string:\n" .. p8);
	p9 = p9 + 1;
	local v14 = 1;
	while true do
		p9 = u7(p8, p9);
		assert(p9 <= v13, "JSON String ended unexpectedly scanning array.");
		local v15 = l__string__1.sub(p8, p9, p9);
		if v15 == "]" then
			break;
		end;
		if v15 == "," then
			p9 = u7(p8, p9 + 1);
		end;
		assert(p9 <= v13, "JSON String ended unexpectedly scanning array.");
		local v16, v17 = u3.decode(p8, p9);
		p9 = v17;
		v12[v14] = v16;
		v14 = v14 + 1;	
	end;
	return v12, p9 + 1;
end;
local function u10(p10, p11)
	local v18 = p11 + 1;
	while l__string__1.find("+-0123456789.e", l__string__1.sub(p10, v18, v18), 1, true) and v18 <= l__string__1.len(p10) do
		v18 = v18 + 1;	
	end;
	local v19 = l__string__1.sub(p10, p11, v18 - 1);
	local v20 = tonumber(v19);
	assert(v20, "Failed to scan number [ " .. v19 .. "] in JSON string at position " .. p11 .. " : " .. v18);
	return v20, v18;
end;
local function u11(p12, p13)
	assert(p13, "decode_scanString(..) called without start position");
	local v21 = l__string__1.sub(p12, p13, p13);
	local v22 = true;
	if v21 ~= "\"" then
		v22 = v21 == "'";
	end;
	assert(v22, "decode_scanString called for a non-string");
	local v23 = {};
	local v24 = p13;
	while l__string__1.find(p12, v21, v24 + 1) ~= v24 + 1 do
		local v25, v26 = l__string__1.find(p12, "\\.", v24 + 1);
		local v27 = v25;
		local v28 = v26;
		local v29, v30 = l__string__1.find(p12, v21, v24 + 1);
		if not v27 or v29 < v27 then
			v27 = v29;
			v28 = v30 - 1;
		end;
		l__table__6.insert(v23, l__string__1.sub(p12, v24 + 1, v27 - 1));
		if l__string__1.sub(p12, v27, v24) == "\\u" then
			local v31 = l__string__1.sub(p12, v24 + 1, v24 + 4);
			v24 = v24 + 4;
			local v32 = tonumber(v31, 16);
			assert(v32, "String decoding failed: bad Unicode escape " .. v31 .. " at position " .. v27 .. " : " .. v24);
			if v32 < 128 then
				local v33 = l__string__1.char(v32 % 128);
			elseif v32 < 2048 then
				v33 = l__string__1.char(192 + l__math__4.floor(v32 / 64) % 32, 128 + v32 % 64);
			else
				v33 = l__string__1.char(224 + l__math__4.floor(v32 / 4096) % 16, 128 + l__math__4.floor(v32 / 64) % 64, 128 + v32 % 64);
			end;
			l__table__6.insert(v23, v33);
		else
			l__table__6.insert(v23, v1[l__string__1.sub(p12, v27, v24)]);
		end;	
	end;
	l__table__6.insert(v23, l__string__1.sub(v24, v24 + 1));
	assert(l__string__1.find(p12, v21, v24 + 1), "String decoding failed: missing closing " .. v21 .. " at position " .. v24 .. "(for string at position " .. p13 .. ")");
	return l__table__6.concat(v23, ""), v24 + 2;
end;
local function u12(p14, p15)
	assert(l__string__1.sub(p14, p15, p15 + 1) == "/*", "decode_scanComment called but comment does not start at position " .. p15);
	local v34 = l__string__1.find(p14, "*/", p15 + 2);
	assert(v34 ~= nil, "Unterminated comment in string at " .. p15);
	return v34 + 2;
end;
local function u13(p16, p17)
	--local v35 = {
	--	true = true, 
	--	false = false, 
	--	null = nil
	--};
	
	local v35 = {["true"] = true, ["false"] = false, ["null"] = nil};
	
	for v36, v37 in pairs({ "true", "false", "null" }) do
		if l__string__1.sub(p16, p17, p17 + l__string__1.len(v37) - 1) == v37 then
			return v35[v37], p17 + l__string__1.len(v37);
		end;
	end;
	assert(nil, "Failed to scan constant from string " .. p16 .. " at starting position " .. p17);
end;
function u3.decode(p18, p19)
	p19 = p19 and p19 or 1;
	p19 = u7(p18, p19);
	assert(p19 <= l__string__1.len(p18), "Unterminated JSON encoded object found at position in [" .. p18 .. "]");
	local v38 = l__string__1.sub(p18, p19, p19);
	if v38 == "{" then
		return u8(p18, p19);
	end;
	if v38 == "[" then
		return u9(p18, p19);
	end;
	if l__string__1.find("+-0123456789.e", v38, 1, true) then
		return u10(p18, p19);
	end;
	if v38 == "\"" or v38 == "'" then
		return u11(p18, p19);
	end;
	if l__string__1.sub(p18, p19, p19 + 1) ~= "/*" then
		return u13(p18, p19);
	end;
	return u3.decode(p18, u12(p18, p19));
end;
local function u14(p20)
	return tostring(p20):gsub(".", function(p21)
		return u2[p21];
	end);
end;
local function u15(p22)
	if p22 == u3.EMPTY_ARRAY then
		return true, 0;
	end;
	if p22 == u3.EMPTY_OBJECT then
		return false;
	end;
	local v39 = 0;
	for v40, v41 in pairs(p22) do
		if type(v40) == "number" and l__math__4.floor(v40) == v40 and v40 >= 1 then
			if not u5(v41) then
				return false;
			end;
			v39 = l__math__4.max(v39, v40);
		elseif v40 == "n" then
			if v41 ~= (p22.n or #p22) then
				return false;
			end;
		elseif u5(v41) then
			return false;
		end;
	end;
	return true, v39;
end;
function u3.encode(p23)
	if p23 == nil then
		return "null";
	end;
	local v42 = type(p23);
	if v42 == "string" then
		return "\"" .. u14(p23) .. "\"";
	end;
	if v42 == "number" or v42 == "boolean" then
		return tostring(p23);
	end;
	if v42 ~= "table" then
		if v42 == "function" and p23 == u3.null then
			return "null";
		else
			assert(false, "encode attempt to encode unsupported type " .. v42 .. ":" .. tostring(p23));
			return;
		end;
	end;
	local v43 = {};
	local v44, v45 = u15(p23);
	if v44 then
		for v46 = 1, v45 do
			l__table__6.insert(v43, u3.encode(p23[v46]));
		end;
	else
		for v47, v48 in pairs(p23) do
			if u5(v47) and u5(v48) then
				l__table__6.insert(v43, "\"" .. u14(v47) .. "\":" .. u3.encode(v48));
			end;
		end;
	end;
	if v44 then
		return "[" .. l__table__6.concat(v43, ",") .. "]";
	end;
	return "{" .. l__table__6.concat(v43, ",") .. "}";
end;
function u3.null()
	return u3.null;
end;
local v49 = {
	Encode = function(p24)

	end, 
	Decode = function(p25)

	end
};
return {
	Encode = u3.encode, 
	Decode = u3.decode
};
